from rest_framework import serializers
from .models import Address


class AddressSerializer(serializers.ModelSerializer):
    class Meta:
        model = Address
        fields = ['id', 'name', 'tel', 'address', 'user', 'isDefault', 'province_name', 'city_name', 'region_name',
                  'detail_address', 'ship_address']

        extra_kwargs = {
            'address': {'read_only': True},
            'id': {'read_only': True},
        }


class UserOneSerializer(serializers.ModelSerializer):
    class Meta:
        model = Address
        fields = ['id', 'name', 'tel', 'user', 'isDefault', 'province_name', 'city_name', 'region_name',
                  'detail_address', 'ship_address']
        extra_kwargs = {
            'id': {'read_only': True},
            'province_name': {'read_only': True},
            'city_name': {'read_only': True},
            'region_name': {'read_only': True},
            'detail_address': {'read_only': True},

            'ship_address': {'read_only': True},
        }


class UserShipSerializer(serializers.ModelSerializer):
    class Meta:
        model = Address
        fields = ['ship_address', 'id']

        extra_kwargs = {'ship_address': {'write_only': True}, }
